import {initGL} from './boot/initGL.ts'
import { initProgram } from './boot/initProgram.ts'
import { Timing } from './time/Timing.ts'

export default class RenderContext {
  static gl = null
  static program = null
  static timing = null

  static init(){
    if(RenderContext.gl){return}
    const gl = initGL()
    const program = initProgram(gl)
    gl.canvas.width = gl.canvas.clientWidth;
    gl.canvas.height =gl.canvas.clientHeight;
    RenderContext.program = program
    RenderContext.gl = gl
    RenderContext.timing = new Timing()
  }

  static getGL(){
    RenderContext.init()
    return RenderContext.gl;
  }

  static getProgram(){
    RenderContext.init()
    return RenderContext.program;
  }

  static getTiming(){
    RenderContext.init()
    return RenderContext.timing;
  }
}
